package com.xucranger.ojapi.controller;


import com.xucranger.ojapi.enity.DTO.UserinfoDTO;
import com.xucranger.ojapi.enity.DTO.common.ResponseDTO;
import com.xucranger.ojapi.enity.VO.UserinfoVO;
import com.xucranger.ojapi.enity.domain.RegisterUser;
import com.xucranger.ojapi.enity.domain.Userinfo;
import com.xucranger.ojapi.service.UserinfoService;
import javafx.geometry.Pos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/userinfo")
public class UserinfoController {

    @Autowired
    UserinfoService userinfoService;


    //用户信息注册By徐鹤翔
    @PostMapping("/register")
    public ResponseDTO userRegister(@Validated @RequestBody RegisterUser registerUser){
        return userinfoService.register(registerUser);
    }


    //用户登陆By徐鹤翔
    @PostMapping("/login")
    public ResponseDTO<UserinfoDTO> userLogin(@Validated @RequestBody Userinfo userinfo){
        return userinfoService.login(userinfo);
    }




    //用户个人信息展示By徐鹤翔
    @GetMapping("/profile/{userid}")
    public ResponseDTO<UserinfoVO> getPofile (@PathVariable("userid") String userid){
        return userinfoService.getPofile(userid);
    }
}
